package com.elec.domain;

import lombok.Data;

import java.util.List;

/**
 * @author yu
 * @date 2024/3/23
 */
@Data
public class R {
    private static final long serialVersionUID = 1L;

    /** 总记录数 */
    private long total;

    /** 列表数据 */
    private List<?> rows;

    /** 消息状态码 */
    private int code;

    /** 消息内容 */
    private String msg;

    private Object data;

    public static R error(String msg){
        R r = new R();
        r.setMsg(msg);
        r.setCode(300);
        return r;
    }

    public static R success(String msg){
        R r = new R();
        r.setMsg(msg);
        r.setCode(200);
        return r;
    }

    public static R success(Object data){
        R r = new R();
        r.setMsg("成功");
        r.setCode(200);
        r.setData(data);
        return r;
    }

    public static R success(List<?> rows, long total){
        R r = new R();
        r.setMsg("成功");
        r.setCode(200);
        r.setRows(rows);
        r.setTotal(total);
        return r;
    }



}
